using System;
using Microsoft.Xna.Framework;

namespace Core
{
    public static class RectangleTools
    {
        public static Rectangle Intersect(Rectangle a, Rectangle b)
        {
            int x = Math.Max(a.X, b.X);
            int num2 = Math.Min((int)(a.X + a.Width), (int)(b.X + b.Width));
            int y = Math.Max(a.Y, b.Y);
            int num4 = Math.Min((int)(a.Y + a.Height), (int)(b.Y + b.Height));
            if ((num2 >= x) && (num4 >= y))
            {
                return new Rectangle(x, y, num2 - x, num4 - y);
            }
            return Rectangle.Empty;
        }
    }
}
